﻿
@{
    ViewBag.Title = "新闻信息列表";
    Layout = "~/Views/Shared/_Index.cshtml";
}


<div class="topPanel">
    <div class="toolbar">
        <div class="btn-group">
            <a class="btn btn-primary" onclick="$.reload()"><span class="glyphicon glyphicon-refresh"></span></a>
        </div>
        <div class="btn-group">
            <a id="NF-add" authorize="yes" class="btn btn-primary dropdown-text" onclick="btn_add()"><i class="fa fa-plus"></i>发布</a>
        </div>
        <div class="operate">
            <ul class="nav nav-pills">
                <li class="first">已选中<span>1</span>项</li>
                <li><a id="NF-edit" authorize="yes" onclick="btn_edit()"><i class="fa fa-pencil-square-o"></i>修 改</a></li>
                <li><a id="NF-delete" authorize="yes" onclick="btn_delete()"><i class="fa fa-trash-o"></i>删 除</a></li>
            </ul>
            <a href="javascript:;" class="close"></a>
        </div>
        <script>$('.toolbar').authorizeButton()</script>
    </div>
    <div class="search">
        <table>
            <tr>
                <td>
                    <div class="input-group">
                        <input id="txt_keyword" type="text" class="form-control" placeholder="标题" style="width: 200px;">
                        <span class="input-group-btn">
                            <button id="btn_search" type="button" class="btn  btn-primary"><i class="fa fa-search"></i></button>
                        </span>
                    </div>
                </td>
            </tr>
        </table>
    </div>
</div>
<div class="gridPanel">
    <table id="gridList"></table>
    <div id="gridPager"></div>
</div>

<script>
    $(function () {
        gridList();
    })
    function gridList() {
        var $gridList = $("#gridList");
        $gridList.dataGrid({
            url: "/SystemManage/RichText/GetGridJson",
            height: $(window).height() - 128,
            colModel: [
                { label: '主键', name: 'F_Id', hidden: true },
                {
                    label: '标 题', name: 'F_Title', width: 260, align: 'left',
                    formatter: function (cellvalue, options, rowObject) {
                        return `<a href="javascript:void(0)" onClick="openNew('${rowObject.F_Id}','通 知')" style="color:blue;text-decoration-line: underline;" >${cellvalue}</a>`
                    }
                },
                { label: '发布人', name: 'F_Spokesman', width: 80, align: 'left' },
                {
                    label: '状 态', name: 'F_Status', width: 60, align: 'center',
                    formatter: function (cellvalue, options, rowObject) {

                        if (cellvalue == true) {
                            return '已发布';
                        } else {
                            return '草稿';
                        }
                    }
                },
                {
                    label: '创建时间', name: 'F_CreatorTime', width: 80, align: 'left',
                    formatter: "date", formatoptions: { srcformat: 'Y-m-d', newformat: 'Y-m-d' }
                },
                { label: '创建人', name: 'F_CreatorUserName', width: 80, align: 'left' },
                {
                    label: '更新时间', name: 'F_LastModifyTime', width: 80, align: 'left',
                    formatter: "date", formatoptions: { srcformat: 'Y-m-d', newformat: 'Y-m-d' }
                },
                { label: '更新人', name: 'F_LastModifyUserName', width: 80, align: 'left' }
                
              
            ],
            pager: "#gridPager",
            sortname: 'F_CreatorTime desc',
            viewrecords: true
        });
        $("#btn_search").click(function () {
            $gridList.jqGrid('setGridParam', {
                postData: { keyword: $("#txt_keyword").val() },
            }).trigger('reloadGrid');
        });
    }

    function btn_add() {
        $.addTab("4BC806F6-3653-40E8-8BDA-CF05B94DCC30", "/SystemManage/RichText/Index?keyValue=", "新增新闻信息");
    }

    function btn_edit() {
        var keyValue = $("#gridList").jqGridRowValue().F_Id;
      //  var title = $("#gridList").jqGridRowValue().F_Title;
        if (keyValue) {
            $.addTab("4BC806F6-3653-40E8-8BDA-CF05B94DCC30" + keyValue, "/SystemManage/RichText/Index?keyValue=" + keyValue, "编辑" );
        }
    }
    function btn_delete() {
        $.deleteForm({
            url: "/SystemManage/RichText/DeleteForm",
            param: { keyValue: $("#gridList").jqGridRowValue().F_Id },
            success: function () {
                $.currentWindow().$("#gridList").trigger("reloadGrid");
            }
        })
    }


    function openNew(id, title) {
        $.addTab(id, "/SystemManage/RichText/Preview?keyValue=" + id, title);
    }

</script>
